﻿using System;
using BakalarskaPraca.Forms;

namespace BakalarskaPraca.Generation.Tasks.Abstract
{
    public abstract class WorkTask
    {
        public delegate void ReportProgress(string message);

        //private readonly ProgressViewer _progressViewer;
        protected string TaskName;
        private int _lastProgress;
        private ReportProgress _reportProgress;

        protected WorkTask(ReportProgress reporter, string taskName)
        {
            //this._progressViewer = progressViewer;
            this.TaskName = taskName;
            //this._lastProgress = -1;
            this._reportProgress = reporter;
        }

        /*protected void ReportProgressState(int progress)
        {
            if (progress != this._lastProgress)
            {
                if (progress < 0 || progress > 100)
                {
                    throw new ArgumentException("Progress cannot be set to " + progress);
                }
                this._lastProgress = progress;
                this._progressViewer.SetState(this.TaskName, progress);
            }
        }
        */
        protected void ReportProgressState(int currentValue, int maxValue)
        {
            this._reportProgress(this.TaskName + " (" + currentValue + "/" + maxValue + ")");
        }
    }
}
